package com.yanqu.road.server.cmd.wingroom.message;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2022/3/21 10:17
 */
@Cmd(code = CrossProtocol.C_WING_ROOM_COPY_OTHER_PLAN, desc = "拷贝别人的方案")
public class CrossCopyOtherPlanCmd extends CrossCommand {
    private long otherPlayerServerId;
    private long otherPlayerUserId;
    private String planUid;
    private String planName;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomProto.GetOtherPlanReqMsg reqCrossMsg = WingRoomProto.GetOtherPlanReqMsg.parseFrom(packet.getBytes());
        otherPlayerServerId = reqCrossMsg.getOtherPlayerServerId();
        otherPlayerUserId = reqCrossMsg.getOtherPlayerUserId();
        planUid = reqCrossMsg.getPlanUid();
        planName = reqCrossMsg.getPlanName();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        WingRoomProto.GetOtherPlanCrossReqMsg.Builder crossReqMsg = WingRoomProto.GetOtherPlanCrossReqMsg.newBuilder();
        crossReqMsg.setPlanUid(planUid);
        crossReqMsg.setPlanName(planName);
        crossReqMsg.setRespServerId(serverId);
        crossReqMsg.setRespUserId(packet.getPlayerId());
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_WING_ROOM_CROSS_COPY_PLAN, crossReqMsg);
        MessageHelper.sendPacket(otherPlayerServerId, otherPlayerUserId, message);
    }

    @Override
    public void sendData() {

    }
}
